package cn.iocoder.yudao.module.mini.dal.mysql.order;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mini.dal.dataobject.order.OrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mini.controller.admin.order.vo.*;

/**
 * 订单 Mapper
 *
 * @author dzy
 */
@Mapper
public interface OrderMapper extends BaseMapperX<OrderDO> {

    default PageResult<OrderDO> selectPage(OrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDO>()
                .eqIfPresent(OrderDO::getNumber, reqVO.getNumber())
                .eqIfPresent(OrderDO::getTechnicianId, reqVO.getTechnicianId())
                .eqIfPresent(OrderDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(OrderDO::getState, reqVO.getState())
                .eqIfPresent(OrderDO::getAddressId, reqVO.getAddressId())
                .eqIfPresent(OrderDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(OrderDO::getTotal, reqVO.getTotal())
                .eqIfPresent(OrderDO::getIsPayment, reqVO.getIsPayment())
                .eqIfPresent(OrderDO::getServiceTime, reqVO.getServiceTime())
                .betweenIfPresent(OrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderDO::getId));
    }

    default List<OrderDO> selectList(OrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrderDO>()
                .eqIfPresent(OrderDO::getNumber, reqVO.getNumber())
                .eqIfPresent(OrderDO::getTechnicianId, reqVO.getTechnicianId())
                .eqIfPresent(OrderDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(OrderDO::getState, reqVO.getState())
                .eqIfPresent(OrderDO::getAddressId, reqVO.getAddressId())
                .eqIfPresent(OrderDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(OrderDO::getTotal, reqVO.getTotal())
                .eqIfPresent(OrderDO::getIsPayment, reqVO.getIsPayment())
                .eqIfPresent(OrderDO::getServiceTime, reqVO.getServiceTime())
                .betweenIfPresent(OrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderDO::getId));
    }

}
